import React, { Component } from 'react';
import style from './index.module.scss'
import HeadBar from '../../components/HeadBar';
import Banner from "./Banner"
import Dtsub from './Dtsub'
import { Toast } from 'antd-mobile'
// import { getDetailApi } from '@/api/Details'
class index extends Component {

    state = {
        id: this.props.match.params.id,
        goodsDetail: {},
        price: {},
        pics: []
    }

    componentDidMount() {

        this.getBanner()
    }

    async getBanner() {
        // let res = await getDetailApi({ goodid: this.props.match.params.id })
        // // console.log(res.data);
        // if (res.data.code === 200) {
        //     this.setState({
        //         price: { ...this.state.goodsDetail.salesPrice },
        //         goodsDetail: { ...res.data.goodinfo },
        //         pics: [...res.data.goodinfo.pics]
        //     })

        // } else {
        //     Toast.show({
        //         content: '商品已下架',
        //         afterClose: () => {
        //             this.props.history.goBack()
        //         },
        //     })
        // }
    }


    render() {
        return (
            <div className={style.details}>
                <div className={style.head}>
                    <div className={style.headbox}></div>
                    <HeadBar title="详情页"></HeadBar>
                </div>
                <div className={style.banner}>
                    <Banner></Banner>
                </div>
                <div className={style.content}>
                    <div className={style.box1}>
                        <span className={style.yuanjia}>原价{this.state.price.value}</span>
                        <span className={style.time}>距结束5天0小时</span>
                    </div>
                    <div className={style.box2}>
                        <p>活动价￥<span>{this.state.price.value}</span></p>
                        <span className={style.baoyou}>包邮包税</span>
                    </div>

                </div>
                <div className={style.titleBox}>
                    <h3>{this.state.goodsDetail.name}</h3>
                    <div>
                        {
                            this.state.pics.map((item, index) => (
                                <img key={index} src={item} alt="" />
                            ))
                        }

                    </div>
                </div>
                <div className={style.asfdg}>
                    <div className={style.box1}></div>
                    <Dtsub id={this.state.id}></Dtsub>
                </div>
            </div>
        );
    }
}

export default index;